Walkthrough 7-4: Use property placeholders in connectors
In this walkthrough, you introduce properties into your API implementation. You will:
· Create a YAML properties file for an application.
· Configure an application to use a properties file.
· Define and use HTTP and Salesforce connector properties.
Starting file
If you did not complete the previous walkthrough, you can get a starting file here. This file is also located in the solutions folder of the student files ZIP located in the Course Resources.
Create a properties file
1. Return to the apdev-examples project.
2. Right-click the src/main/resources folder in the Package Explorer and select New > File.
3. Set the file name to config.yaml and click Finish.
Create a Configuration properties global element
4. Return to global.xml.
5. In the Global Elements view, click Create.
6. In the Choose Global Type dialog box, select Global Configurations > Configuration properties and click OK.
7. In the Global Element Properties dialog box, set the file to config.yaml and click OK.
Parameterize the HTTP Listener port
8. Return to config.yaml.
9. Define a property called http.port and set it to 8081.
10. Save the file.
11. Return to global.xml.
12. Double-click the HTTP Listener config global element.
13. Change the port from 8081 to the application property, ${http.port}.
14. Click OK.
Parameterize the Salesforce credentials
15. Double-click the Salesforce Config global element.
16. Copy the username value and click OK.
17. Return to config.yaml.
18. Define a property called sfdc.username and set it to your Salesforce username.
19. Add properties for password and token and set them to your values.
20. Save the file.
21. Return to global.xml.
22. Double-click the Salesforce Config global element.
23. Change the values to use the application properties.
24. Click Test Connection and make sure it succeeds.
Note: If your connection fails, click OK and then go back and make sure you do not have any syntax errors in config.yaml and that you saved the file.
25. Click OK.
26. In the Global Element Properties dialog box, click OK.
Test the application
27. Save all files to redeploy the application.
28. In Advanced REST Client, make the same request to http://localhost:8081/sfdc and confirm you still get data.
29. Return to Anypoint Studio and stop the project.